/**
 * @Description:
 * @author g
 * @email g900859@163.com
 * @date 2023/3/14
 *
 * @function locals 初始化全局数据的中间件
 * @param options 待使用的配置对象
 * @return {(function(*, *, *): void)|*}
 */
module.exports = function (options) {
  let locals = function (req, res, next) {
    //创建全局数据
    for (let localsKey in options) {
      req.app.locals[localsKey] = options[localsKey]
    }

    next()
  }
  return locals
}
